<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib uri="http://www.ufida.com/lfw" prefix="lfw" %>
<%@ taglib uri="http://www.ufida.com/uif" prefix="uif" %> 
<%@ taglib uri="http://www.ufida.com/lfwtool" prefix="lfwtool" %> 
<%@ taglib uri="http://www.ufida.com/multilang" prefix="ml" %>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
<%@page import="nc.lfw.core.LfwRuntimeEnvironment"%>
<html>
	<head>
		<lfw:base/>
		<lfw:head/>
		<uif:import/>
		<script type='text/javascript' src='<%= "code/" + request.getParameter("pageId") %>'></script>
	</head>
	<body bottommargin="0" topmargin="0" leftmargin="0" rightmargin="0" scroll=no onload="pageBodyScript()" style="background-color:transparent;">
		<lfw:pageModel className="nc.lfw.core.model.ConfigurationPageModel">
			<lfw:layout type="border">
				<lfw:layoutPanel position="center">
					<lfw:layout type="flowh">
						<lfw:layoutPanel align="left">
							<lfw:tree id="prefsTree" />
						</lfw:layoutPanel>
					</lfw:layout>
				</lfw:layoutPanel>
				<lfw:layoutPanel position="bottom" height="34">
					<lfw:layout type="flowh">
						<lfw:layoutPanel>
							<lfw:button id="okbt" />
						</lfw:layoutPanel>
						<lfw:layoutPanel>
							<lfw:button id="cancelbt" />
						</lfw:layoutPanel>
					</lfw:layout>
				</lfw:layoutPanel>
			</lfw:layout>
		</lfw:pageModel>
	</body>
	<script>
		function doPrefs(node)
		{
			if(node == null)
				return;
			//"_level1";
			var len = node.id.length;
			var end = len - 7;
			var nodeId = node.id.substring(0,end);	
			if(nodeId == "logout")
			{	
				parent.logout();
			}
			else if(nodeId == "password")
			{
				modifyPWD();
			}
			else if(nodeId == "simpchn" || nodeId == "tradchn" || nodeId == "english")
			{
				// 首先设置cookie
				document.cookie = "GUEST_LANGUAGE_ID=" + nodeId;
				var cmd = new CommonCommand('changeLang');
				cmd.setAsync(false);
				cmd.setParameter("langId=" + nodeId);
				var result = cmd.exec();
				//var result = processCommonLogic("langId=" + nodeId, "changeLang", null, null, false, null, null);
				if(result == "success")
				{
					//修改成功,是否注销以启用新的皮肤
					var chn = "${ml:trans('WebBxPreferenceHandler-000006')}";
					if(nodeId == "tradchn")
						chn = "${ml:trans('WebBxPreferenceHandler-000007')}";
					else if(nodeId == "english")
						chn = "${ml:trans('WebBxPreferenceHandler-000008')}";	
					showConfirmDialog("${ml:trans('yer_prefs001')}" + chn + "${ml:trans('yer_prefs002')}", ok);
					function ok(){
						parent.logout();
					}
				}
			}
			else if(nodeId == "ncclassic")
			{
				var cmd = new CommonCommand('changeTheme');
				cmd.setAsync(false);
				cmd.setParameter("themeId=ncclassic");
				var result = cmd.exec();
				//var result = processCommonLogic("themeId=ncclassic", "changeTheme", null, null, false, null, null);
				if(result == "success")
				{
					//修改成功,是否注销以启用新的皮肤
					showConfirmDialog("${ml:trans('yer_prefs003')}", ok);
					function ok(){
						parent.logout();
					}
				}
			}
			else if(nodeId == "webclassic")
			{
				var cmd = new CommonCommand('changeTheme');
				cmd.setAsync(false);
				cmd.setParameter("themeId=webclassic");
				var result = cmd.exec();
				//var result = processCommonLogic("themeId=webclassic", "changeTheme", null, null, false, null, null);
				if(result == "success")
				{
					//修改成功,是否注销以启用新的皮肤
					showConfirmDialog("${ml:trans('yer_prefs004')}", ok);
					function ok(){
						parent.logoutFunc();
					}
				}
			}
		}
		
		/**
		 * 修改密码
		 */
		function modifyPWD()
		{	 
			var url = getCorePath() + "/modifypwd.jsp?pageId=modifypwd&rand=" + (Math.random()*10000).toString().substring(0, 4);
			showDialog(url , "${ml:trans('yer_prefs005')}", "300", "200", "modifypwd", true,true);
		}		
	</script>
</html>